Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

popfun

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popfun

pop array, if last element is function

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

popfun - pop function

The popfun Node.js module removes the last element from an array if it is a function and returns it. This can be handy to fetch the callback from an arguments array ([err, a1, a2, an, cb]).

Build Status

Example

var popfun = require('popfun')

function echo () {
  var args = Array.prototype.slice.call(arguments)
  var callback = popfun(args)
  if (callback) callback(null, args.join(' '))
}

echo('hey', 'you', function (err, msg) {
  console.log(msg)
})

Exports

popfun(args)

  • args Object to pop if last element is of type 'function'

This function can take any type. If it receives an array, it pops the last element, and returns the element; else it returns null.

Installation

With npm do:

npm install popfun

License

MIT License

Keywords

FAQs

Package last updated on 08 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc